/**
 * @projectName study-note
 * @package Singleton
 * @className Singleton.Singleton04
 */
package Singleton;

/**
 * Singleton04
 * @description 单例模式--枚举
 * @author answer_wx
 * @date 2022/7/4 14:49
 * @version 1.0
 */
public class Singleton04 {
    private Singleton04() {
    }

    /**
     * 定义静态枚举类
     */
    private enum Singleton04Enum {
        /**
         * 创建一个枚举对象，默认单例
         */
        INSTANCE;
        private Singleton04 singleton04;

        Singleton04Enum() {
            singleton04 = new Singleton04();
        }

        private Singleton04 getInstance() {
            return singleton04;
        }
    }

    public static Singleton04 getInstance() {
        return Singleton04Enum.INSTANCE.getInstance();
    }
}